import java.util.Arrays;

//调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
//
//如数组：[1,2,3,4,5,6]
//
//调整后可能是：[1, 5, 3, 4, 2, 6]

public class Test {
    public static void func(int [] array) {
        int left = 0;
        int right = array.length-1;
        while(left < right) {
            while(left < right && array[left] % 2 != 0) {
                left++;
            }
            while(left < right && array[right] % 2 == 0) {
                right--;
            }
            swap(array,left,right);
        }
    }

    public static void swap(int[] array,int i,int j) {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }

    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6};
        func(array);
        System.out.println(Arrays.toString(array));
    }
}
